<template>
	<view class="jui_main ">
		<view class="jui_h100"></view>
		<view class="jui_h60"></view>
		<view class="jui_flex_col_center">
			<image class="avatar" src="/static/imgs/avatar.png"></image>
		</view>
		<view class="jui_h100"></view>
		<view class="jui_h60"></view>
		<view>
			<view class="jui_font_weight  title" style="padding-left: 40rpx;">密码登录</view>
			<view class="jui_h60"></view>
			<view class="jui_pad_2432">
				<input type="text" placeholder="请输入手机号码" class="jui_bor_bottom jui_pad_b20 jui_fs32"
					style="height: 60rpx;" v-model="info.username" />
				<view class="jui_h30"></view>
				<view class="jui_h20"></view>
				<view class="jui_bor_bottom jui_pad_b20 jui_flex jui_flex_justify_between jui_flex_items_center">
					<input :type="iptType[0].type" placeholder="请输入登录密码" class="jui_fs32" v-model="info.password"
						style="border: none;outline: none;height: 60rpx;" />

					<image :src="iptType[0].viewno ? imgSrc : noView" class="pwdPic" @click="changeType(0)"></image>
				</view>
			</view>
			<view class="jui_pad_2432 jui_flex jui_flex_justify_between jui_flex_items_center ">
				<view class="reg" @tap="regi">注册</view>
				<view class="pwd" @tap="forget">忘记密码</view>
			</view>
			<view class="jui_h60"></view>
			<view class="jui_pad_2432">
				<view @tap="login" class="login jui_bor_rad_40 pad jui_text_center   jui_fc_fff jui_fs30">登录</view>
			</view>
		</view>
	</view>
</template>

<script>
	const view = require('../../static/imgs/home/view_no.png');
	const util = require('../../tool/util');
	export default {
		data() {
			return {
				iptType: [{
					type: 'password',
					viewno: true
				}],
				imgSrc: require('@/static/imgs/home/view_no.png'),
				noView: require('@/static/imgs/home/view.png'),
				info: {},
				
			};
		},
		onLoad() {

		},
		methods: {
			regi() {
				uni.navigateTo({
					url: 'register'
				});
			},
			forget() {
				uni.navigateTo({
					url: 'forgetPwd'
				});
			},
			changeType(index) {
				if (this.iptType[index].type == 'text') {
					this.iptType[index].type = 'password';
					this.iptType[index].viewno = true;
				} else {
					this.iptType[index].type = 'text';
					this.iptType[index].viewno = false;
				}
			},
			login() {
				if (!this.info.username) {
					return this.$msg('请输入手机号码');
				}
				if (!this.info.password) {
					return this.$msg('请输入登录密码');
				}
				let ticket = util.uuid();
				this.info._token = ticket
				this.$api.login(this.info).then(res => {
					if (res.ok) {
						this.$msg(res.msg);
						uni.setStorageSync('token', res.data.token);
						uni.setStorageSync('uid', res.data.id);
						uni.setStorageSync('effective', res.data.effective);
						uni.setStorageSync('supperNodeName', res.data.supperNodeName);
						uni.setStorageSync('walleturl', res.data.walleturl);
						uni.setStorageSync('fee', res.data.fee);
						uni.setStorageSync('digitalMoney', res.data.digitalMoney);
						uni.setStorageSync('kaffect', res.data.kaffect);
						uni.setStorageSync('countwallet', res.data.countwallet);
						uni.setStorageSync('cnywallet', res.data.cnywallet);
						uni.setStorageSync('digitalwallet', res.data.digitalwallet);
						uni.setStorageSync('lockcnywallet', res.data.lockcnywallet);
						uni.setStorageSync('lockdigitalwallet', res.data.lockdigitalwallet);
						uni.setStorageSync('config', JSON.stringify(res.data.config));
						uni.setStorageSync('model', res.data.config.model);
						setTimeout(() => {
							uni.switchTab({
								url: `/pages/home/home`
							});
						}, 800);
					} else {
						this.$msg(res.msg);
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}
	.avatar{
		width: 320px;
		height: 160px;
	} 
	.title {
		font-size: 50upx;
		color: #383630;
	}
	input {
		outline: none;
	}
	input:focus {
		outline: none;
	}
	.pwdPic {
		height: 50upx;
		width: 50upx;
	}
	.reg {
		font-size: 32upx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #383630;
	}
	.pwd {
		font-size: 28upx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #383630;
	}
	.login {
		background-color: $zhuse;
	}
	.pad {
		padding: 20rpx 0;
	}
</style>
